<template>
  <div class="container">
    <!-- 内容部分 -->
    <div class="operate">
      <slot></slot>
      <div style="margin-right: auto"></div>
      <slot name="op"></slot>
    </div>
    <div class="content" :style="{ maxHeight: item.h * 40 - 80 + 'px' }">
      <Chart :spec="spec" />
    </div>
  </div>
</template>

<script setup lang="ts">
  /**
   * @description 业务组件 -- 公告
   */
  import { defineProps } from "vue";
  import Chart from "./Chart.vue";
  defineProps(["item"]);
  const spec = {
    type: "pie",
    data: [
      {
        name: "data1",
        values: [
          {
            value: 300,
            name: "A",
            radius: 100,
          },
          {
            value: 120,
            name: "B",
            radius: 95,
          },
          {
            value: 100,
            name: "C",
            radius: 90,
          },
          {
            value: 80,
            name: "D",
            radius: 85,
          },
        ],
      },
    ],
    valueField: "value",
    categoryField: "name",
    seriesField: "name",
    radius: 0.8,
    innerRadius: 0.5,
    startAngle: -90,
    endAngle: 250,
    pie: {
      style: {
        outerRadius: (datum) => {
          return datum.radius;
        },
        innerRadius: (datum) => {
          return 60;
        },
        cornerRadius: 2,
      },
    },

    animationNormal: {
      pie: [
        {
          startTime: 100,
          loop: 0,
          timeSlices: [
            {
              effects: {
                channel: {
                  fillOpacity: { to: 0.3 },
                },
              },
              duration: 500,
            },
          ],
        },
        {
          loop: true,
          startTime: 800,
          oneByOne: true,
          timeSlices: [
            {
              effects: {
                channel: {
                  fillOpacity: { to: 1 },
                  outerRadius: { to: (datum) => datum.radius + 10 },
                },
              },
              duration: 500,
            },
            {
              effects: {
                channel: {
                  fillOpacity: { to: 1 },
                  outerRadius: { to: (datum) => datum.radius + 10 },
                },
                easing: "linear",
              },
              duration: 500,
            },
            {
              effects: {
                channel: {
                  fillOpacity: { to: 0.3 },
                  outerRadius: { to: (datum) => datum.radius },
                },
              },
              duration: 500,
            },
          ],
        },
      ],
    },
    tooltip: {
      visible: false,
    },
    indicator: {
      id: "indicator",
      visible: true,
      fixed: true,
      content: [
        {
          visible: true,
          style: {
            fontSize: 20,
            text: "Total: 600",
            fillOpacity: 0.8,
            fontWeight: 600,
          },
        },
      ],
    },
  };
</script>

<style scoped lang="scss">
  .container {
    user-select: none;
    box-sizing: border-box;
    display: flex;
    flex-direction: column;
    height: 100%;
    padding: 0px 10px 10px;
    font-size: 14px;
    color: #999;
    .content {
      flex: 1;
      display: flex;
      flex-direction: column;
      margin-top: 10px;
      overflow: hidden;
    }
  }

  .content-item {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
  }
  .content-item-main {
    display: flex;
    flex-direction: column;
  }
  .operate {
    display: flex;
    flex-direction: row;
    align-items: center;
    justify-content: flex-end;
  }
</style>
